﻿<UserControl x:Class="uTorrentSL.Views.FeedsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cx="clr-namespace:uTorrentSL.Behaviors"
             xmlns:cv="clr-namespace:uTorrentSL.Converters"
             xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
             
             mc:Ignorable="d"
             DataContext="{Binding FeedsViewModel, Source={StaticResource Locator}}">
    <UserControl.Resources>
        <cv:FeedUrlConvert x:Key="UrlConvert"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Margin="0,0,50,0">
            <HyperlinkButton HorizontalAlignment="Right" Style="{StaticResource LinkStyle}" MinHeight="0" MinWidth="0" Padding="0,0,5,0" FontSize="18" Content="+ new" Margin="0,0,0,0">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding LaunchModalCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="AddFeed" />
                        
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </HyperlinkButton>
        </Grid>
        <ListBox x:Name="lbFeeds" ItemsSource="{Binding Path=Data.Feeds}" Grid.Row="1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Border Canvas.ZIndex="10" Background="Transparent">
                            <i:Interaction.Triggers>
                                <cx:DoubleClickTrigger>
                                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding FeedsViewModel.SelectCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding ElementName=lbFeeds, Path=SelectedItem}"/>
                                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding Main.SetControl, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="FeedView"/>
                                </cx:DoubleClickTrigger>
                            </i:Interaction.Triggers>
                        </Border>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Url, Converter={StaticResource UrlConvert}}"/>

                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
